package org.dromara.learning_lhz.controller;


import org.dromara.learning_lhz.entity.AsQuestionBankEntity;
import org.dromara.learning_lhz.service.QuestionBankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 题库控制器，负责处理题库相关的HTTP请求
 */
@RestController
@RequestMapping("/QuestionBank")
public class QuestionBankController {

    // 注入题库服务层实例
    @Autowired
    private QuestionBankService questionBankService;

    /**
     * 查询题库
     *
     * @param asQuestionBankEntity 查询条件实体
     * @return 题库实体列表
     */
    @PostMapping("selBank")
    public List<AsQuestionBankEntity> selBank(@RequestBody AsQuestionBankEntity asQuestionBankEntity)
    {
       return questionBankService.selBank(asQuestionBankEntity);
    }

    /**
     * 添加题库
     *
     * @param asQuestionBankEntity 待添加的题库实体
     */
    @PostMapping("addBank")
    public void addBank(@RequestBody AsQuestionBankEntity asQuestionBankEntity)
    {
        questionBankService.addBank(asQuestionBankEntity);
    }

    /**
     * 删除题库
     *
     * @param asQuestionBankEntity 待删除的题库实体
     */
    @PostMapping("delBank")
    public void delBank(@RequestBody AsQuestionBankEntity asQuestionBankEntity)
    {
        questionBankService.removeById(asQuestionBankEntity.getId());
    }

    /**
     * 更新题库
     *
     * @param asQuestionBankEntity 待更新的题库实体
     */
    @PostMapping("updateBank")
    public void updateBank(@RequestBody AsQuestionBankEntity asQuestionBankEntity)
    {
        questionBankService.updateById(asQuestionBankEntity);
    }
}
